package com.wwwarehouse.taskcenter.fragment.job_point.step4;

import android.os.Bundle;

import com.alibaba.fastjson.JSON;
import com.wwwarehouse.common.fragment.CommonBasePagerFragment;
import com.wwwarehouse.common.tools.LogUtils;
import com.wwwarehouse.taskcenter.R;
import com.wwwarehouse.taskcenter.bean.job_point.AddJobPointStep4LookmessResponseBean;
import com.wwwarehouse.taskcenter.constant.TaskCenterConstant;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @创建者 minifly.
 * @创建时间 2017/10/25 18:53
 * @描述 ${TODO}
 */

public class ChooseJobUnitLookmesspagerFragment4 extends CommonBasePagerFragment{

    public static final int REQUEST_CODE = 10004;

    private String jobPointUkid;
    private ArrayList<AddJobPointStep4LookmessResponseBean.ListBean> lists1;

    @Override
    public void setTitle() {
        if (peekFragment() instanceof ChooseJobUnitLookmesspagerFragment4) {
            mActivity.setTitle("" + getString(R.string.new_task_step6_select));
        }
    }

    @Override
    public void requestDatas() {
        super.requestDatas();

        jobPointUkid = getArguments().getString("jobPointUkid");

        showConfirmButton();
        hideConfirmButton();
        setConfirmBtnText("" + getString(R.string.new_task_save));
        requestHttp();
    }

    @Override
    public void onDownPull() {
    }

    private void initPager() {

        Bundle budle = new Bundle();
        try {
            setData(lists1.size(), 10, "com/wwwarehouse/taskcenter/fragment/job_point/step4/ChooseJobUnitLookmessDetailFragment4", budle, lists1);
        } catch (Exception e) {
            e.printStackTrace();
            LogUtils.showErrLog("error:"+e.getMessage());
        }
    }

    /**
     * 查询类目
     */
    private void requestHttp() {
        Map<String, Object> map = new HashMap<>();
        map.put("jobPointUkid", jobPointUkid);
        loadData(TaskCenterConstant.URL_TASKPOINT_BINDINGPRODUCT, map, REQUEST_CODE);
    }

    @Override
    public void onRefreshListener() {
    }

    @Override
    public void onLoadSuccess(String s, int i) {
        lists1 = (ArrayList<AddJobPointStep4LookmessResponseBean.ListBean>) JSON.parseArray(s,AddJobPointStep4LookmessResponseBean.ListBean.class);
        initPager();
    }

    @Override
    public void onLoadError(String s) {
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

}
